
{extend name="public:base" /}

{block name="body"}

  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-rule-add" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">上级菜单</label>
      <div class="layui-input-block">
	  <div id="menuSelectBox" class="ew-xmselect-tree"></div>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">菜单名称</label>
      <div class="layui-input-inline">
        <input type="text" name="title" lay-verify="required" placeholder="请输入菜单名" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">权限地址</label>
      <div class="layui-input-inline">
        <input type="text" name="name" lay-verify="required" placeholder="请输入权限地址" autocomplete="off" class="layui-input">
      </div>
    </div>
	
    <div class="layui-form-item">
      <label class="layui-form-label">图标</label>
      <div class="layui-input-inline">
		<input type="text" name="icon" id="iconPicker" lay-filter="iconPicker" style="display:none;">
      </div>
    </div>
	<div class="layui-form-item">
      <label class="layui-form-label">排序</label>
      <div class="layui-input-inline">
        <input type="text" name="sort" lay-verify="" placeholder="排序序号" autocomplete="off" class="layui-input">
      </div>
    </div>
	<div class="layui-form-item">
      <label class="layui-form-label">类型</label>
      <div class="layui-input-block">
        <input type="radio" name="ishidden" lay-skin="primary" title="目录" value="-1">
		<input type="radio" name="ishidden" lay-skin="primary" title="菜单" value="1"  checked>
		<input type="radio" name="ishidden" lay-skin="primary" title="按钮" value="0">
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="LAY-user-rule-submit" id="LAY-user-rule-submit" value="确认">
    </div>
  </div>

{/block}
{block name="js"}  
  <script>
  layui.config({
    base: '/static/admin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','admin', 'xmSelect', 'iconPicker'], function(){
    var $ = layui.$
    ,form = layui.form ;
	var admin = layui.admin;
	var xmSelect = layui.xmSelect;
	var iconPicker = layui.iconPicker;
	
	
	//初始化图标选择
        iconPicker.render({
            elem: '#iconPicker',
            type: 'fontClass',
            search: false,
            page: true,
            limit: 12,
            click: function (data) {
				//console.log(data);
            }
        });
		
	//权限菜单结构
	admin.req({
	type: "post",
	url: "{:url('AuthRule/tree')}", 
	data:{},
	done:function(res){
		var data = res.data;
		
            // 渲染下拉树
            xmSelect.render({
                el: '#menuSelectBox',
                name: 'pid',
                height: '250px',
                layVerify: 'required',
                layVerType: 'tips',
                data: data,
                initValue:  [],
                model: {label: {type: 'text'}},
                prop: {
                    name: 'title',
                    value: 'id'
                },
                radio: true,
                clickClose: true,
                tree: {
                    show: true,
                    indent: 15,
                    strict: false,
                    expandedKeys: true
                },
                tips: '请选择上级菜单'
            });
        }
		
	});

	
  });
  </script>
{/block}